package cn.tedu.clyback.menu.controller;


import cn.tedu.clyback.base.response.JsonResult;
import cn.tedu.clyback.department.pojo.dto.DepartmentSaveParam;
import cn.tedu.clyback.menu.pojo.dto.MenuSaveParam;
import cn.tedu.clyback.menu.pojo.dto.MenuSelectParam;
import cn.tedu.clyback.menu.pojo.vo.MenuVO;
import cn.tedu.clyback.menu.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/menu")
public class MenuController {
    @Autowired
    MenuService menuService;

    @GetMapping("/select")
    public JsonResult selectMenu(MenuSelectParam menuSelectParam){
      log.debug("开始处理【查询菜单】的请求，参数：{}", menuSelectParam);
        List<MenuVO> list = menuService.selectMenu(menuSelectParam);
        log.debug("查询结果：{}", list);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    public JsonResult saveMenu(MenuSaveParam menuSaveParam){
        log.debug("开始处理【保存菜单】的请求，参数：{}", menuSaveParam);
        menuService.saveMenu(menuSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{menuId}")
    public JsonResult delMenu(@PathVariable Integer menuId){
        log.debug("开始处理【删除菜单】的请求，参数：{}", menuId);
        menuService.deleteMenu(menuId);
        return JsonResult.ok();
    }
}